#ifndef _SEMATHUTIL_H_
#define _SEMATHUTIL_H_
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/matrix_decompose.hpp>

namespace SEngine {

    struct Decomposer
    {
        Decomposer(glm::mat4 & m) {
            matrix = m;
            glm::vec3 skew;
            glm::vec4 perspactive;
            glm::decompose(matrix, scale, quat, translate, skew, perspactive);
        }
        glm::mat4 matrix;
        glm::vec3 translate;
        glm::vec3 scale;
        glm::quat quat;
    };

    struct SphericalCoord
    {
        float r;
        float theta;
        float phi;
    };

    /**
     * @brief 基于opengl坐标系
    */
    SphericalCoord CartesianToSpherical(const glm::vec3& cartesian);
    
    /**
     * @brief 基于opengl坐标系
    */
    glm::vec3 SphericalToCartesian(const SphericalCoord& coord);

    /**
     * @brief 球面插值, r必须相同否则抛出异常
    */
    glm::vec3 MixSphere(const glm::vec3& begin, const glm::vec3& end, float a);

}

#endif